package test;

/**
 * Created by key on 2015/2/15.
 */
public class ThreadInterrupt implements Runnable{
    private int count = 20;
    public void fun(){
        if (count>0){
            try{
                Thread.sleep(500);
            }catch (InterruptedException e){
                e.printStackTrace();
            }

            System.out.println(Thread.currentThread().getName()+"剩余数量:"+count--);
        }


    }
    public void run(){
        while(count>0){
            this.fun();
        }
//        try {
//            System.out.println("线程休眠");
//            Thread.sleep(2000);
//        }catch (InterruptedException e){
//            System.out.println("线程中断");
//        }

    }
}
